/**
 * Created by Administrator on 2018/3/26.
 */
'use strict';
let Response = require('../../../model/Response');
let RestifyProxy = require('../../../util/RestifyProxy');
let CustomPageBean = require('../../../model/CustomPageBean');
let runMontiorService = require('../../../service/runMontiorService');
let logger = require('../../../util/LoggerUtil').logger('runMontiorController.js');

/**
 * 账户管理-页面
 */
module.exports.runMontiorPage = function () {
    let response = new Response();
    response.render('back/runMontior/runMontior');
    this.resolve(response);
};
module.exports.runMontiorTree = async function () {   //加载 单灯ztree
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await runMontiorService.getTreeList(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
module.exports.controlLight = async function () {    //单灯控制 按钮
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await runMontiorService.controlLight(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
module.exports.lightList = async function () {  //单灯信息详情
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await runMontiorService.lightList(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
module.exports.logList = async function () {    //终端日志
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await runMontiorService.getlogList(this, params);
        let pageBean = new CustomPageBean(result);
        response.send(pageBean);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
